package com.ruoyi.scheme.mapper;

import com.ruoyi.scheme.pojo.ErsCostItemTemplate;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ErsCostItemTemplateMapper {

    @Insert("INSERT INTO ers_cost_item_template(template_id, item_name, category, unit, unit_price, create_time, update_time) " +
            "VALUES (#{templateId}, #{itemName}, #{category}, #{unit}, #{unitPrice}, now(), now())")
    int insert(ErsCostItemTemplate template);

    @Update("UPDATE ers_cost_item_template SET template_id=#{templateId}, item_name=#{itemName}, " +
            "category=#{category}, unit=#{unit}, unit_price=#{unitPrice}, update_time=now() WHERE id=#{id}")
    int update(ErsCostItemTemplate template);

    @Delete("DELETE FROM ers_cost_item_template WHERE id=#{id}")
    int deleteById(Long id);

    @Select("SELECT * FROM ers_cost_item_template WHERE id=#{id}")
    ErsCostItemTemplate selectById(Long id);

    @Select("SELECT * FROM ers_cost_item_template ORDER BY id ASC")
    List<ErsCostItemTemplate> selectAll();

    @Select("SELECT * FROM ers_cost_item_template WHERE template_id=#{templateId} ORDER BY id ASC")
    List<ErsCostItemTemplate> selectByTemplateId(Short templateId);
}
